package org.kzwl.service.web.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.kzwl.comm.pojo.ResponseData;
import org.kzwl.comm.pojo.bo.QueryThearCategoryBO;
import org.kzwl.comm.utils.PagingCondition;
import org.kzwl.entity.web.CuHeritageCategory;
import org.kzwl.entity.web.ThearCategory;
import org.kzwl.entity.web.Town;
import org.kzwl.mapper.web.ThearCategoryMapper;
import org.kzwl.mapper.web.TownMapepr;
import org.kzwl.service.web.ThearCategoryService;
import org.kzwl.service.web.TownService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ThearCategoryServiceImpl extends ServiceImpl<ThearCategoryMapper, ThearCategory> implements ThearCategoryService {
    @Override
    public ResponseData<List<ThearCategory>> queryList( QueryThearCategoryBO queryThearCategoryBO) {

        return new ResponseData<>(this.baseMapper.selectList(new QueryWrapper<ThearCategory>().lambda().eq(ThearCategory::getCuTownId,queryThearCategoryBO.getCuTownId())));
    }

    @Override
    public ResponseData<IPage<ThearCategory>> queryPage(QueryThearCategoryBO queryThearCategoryBO) {
        return new ResponseData<>(this.baseMapper.selectPage(new Page<>(queryThearCategoryBO.getCurrent(),queryThearCategoryBO.getSize()),new QueryWrapper<ThearCategory>().lambda().eq(ThearCategory::getCuTownId,queryThearCategoryBO.getCuTownId())));
    }

    @Override
    public ResponseData<Void> saveOne(ThearCategory cuHeritageCategory) {
        this.baseMapper.insert(cuHeritageCategory);
        return new ResponseData<>();
    }

    @Override
    public ResponseData<Void> updateOne(ThearCategory cuHeritageCategory) {
        this.baseMapper.updateById(cuHeritageCategory);
        return new ResponseData<>();
    }

    @Override
    public ResponseData<ThearCategory> queryOne(Long Id) {
        return new ResponseData<>(this.baseMapper.selectById(Id));
    }

    @Override
    public ResponseData<Void> deleteId(Long Id) {
        this.baseMapper.deleteById(Id);
        return new ResponseData<>();
    }
}
